package com.smartleanx.module.hrm.dal.mysql.employee;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.smartleanx.framework.mybatis.core.mapper.BaseMapperX;
import com.smartleanx.module.bpm.enums.task.BpmProcessInstanceStatusEnum;
import com.smartleanx.module.hrm.dal.dataobject.employee.EmployeeTransferRecordDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
 * 员工岗位/职位变更记录 Mapper
 *
 * @author 精益大师
 */
@Mapper
public interface EmployeeTransferRecordMapper extends BaseMapperX<EmployeeTransferRecordDO> {

    default List<EmployeeTransferRecordDO> getCurrentTransferRecord(Collection<Long> employeeIds) {
        return selectList(new LambdaQueryWrapper<EmployeeTransferRecordDO>()
                .in(EmployeeTransferRecordDO::getEmployeeId, employeeIds)
                .eq(EmployeeTransferRecordDO::getApproveResult, BpmProcessInstanceStatusEnum.APPROVE.getStatus())
                .orderByDesc(EmployeeTransferRecordDO::getId));
    }

    default List<EmployeeTransferRecordDO> selectListByEmployeeId(Collection<Long> employeeIds, Integer changeType) {
        return selectList(new LambdaQueryWrapper<EmployeeTransferRecordDO>()
                .in(EmployeeTransferRecordDO::getEmployeeId, employeeIds)
                .eq(EmployeeTransferRecordDO::getChangeType, changeType)
        );
    }
    default List<EmployeeTransferRecordDO> getTransferRecordList(Long employeeId) {
        return selectList(EmployeeTransferRecordDO::getEmployeeId, employeeId);
    }
}
